package com.kingzoder.food.controller;

import com.kingzoder.food.common.base.BaseController;
import com.kingzoder.food.common.base.ResultVO;
import com.kingzoder.food.common.base.page.PageResultVO;
import com.kingzoder.food.model.dto.recipe.AddRecipeDTO;
import com.kingzoder.food.model.dto.recipe.EditRecipeDTO;
import com.kingzoder.food.model.dto.recipe.SearchRecipeDTO;
import com.kingzoder.food.model.vo.recipe.RecipeDetailVO;
import com.kingzoder.food.model.vo.recipe.RecipeVO;
import com.kingzoder.food.service.RecipeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZoderKing
 */
@Tag(name = "APP-食谱接口")
@RestController
@RequestMapping("/recipes")
@RequiredArgsConstructor
public class RecipeController implements BaseController<RecipeVO, RecipeDetailVO, SearchRecipeDTO, AddRecipeDTO, EditRecipeDTO> {

    private final RecipeService recipeService;

    @Operation(summary = "分页查询")
    @Override
    public PageResultVO<List<RecipeVO>> queryPage(SearchRecipeDTO queryDTO) {
        return recipeService.queryPage(queryDTO);
    }

    @Operation(summary = "查询单个")
    @Override
    public ResultVO<RecipeDetailVO> queryOne(Long id) {
        return recipeService.queryOne(id);
    }

    @Operation(summary = "添加食谱")
    @Override
    public ResultVO<Boolean> add(AddRecipeDTO addDTO) {
        return recipeService.add(addDTO);
    }

    @Operation(summary = "修改食谱")
    @Override
    public ResultVO<Boolean> edit(EditRecipeDTO updateDTO) {
        return recipeService.edit(updateDTO);
    }

    @Operation(summary = "删除食谱")
    @Override
    public ResultVO<Boolean> remove(Long id) {
        return recipeService.remove(id);
    }

}
